package com.liliya.api;

import cn.hutool.json.JSONUtil;
import com.liliya.pojo.SubCate;
import com.liliya.service.SubCateService;
import com.liliya.service.impl.SubCateServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @Description TODO
 * @Author hhy
 * @Date 2021/1/13 19:27
 */
@WebServlet(urlPatterns="/pro/subcatelist")
public class SubCateList extends HttpServlet {
    SubCateService subCateService = new SubCateServiceImpl();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        resp.setContentType("application/json; charset=utf-8");
        String catenum = req.getParameter("catenum");
        List<SubCate> subcates = subCateService.findSubCate(1, subCateService.totalSubCate(), Integer.parseInt(catenum));
        String s = JSONUtil.toJsonStr(subcates);
        resp.getWriter().write(s);
    }
}
